﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WooCoo.ObjectModel;

namespace WooCoo
{
    /// <summary>
    /// 程序运行时环境，一般在程序启动初化时，如Application_Start方法
    /// </summary>
    public static class RuntimeEnvironment
    {
        static RuntimeEnvironment()
        {
            Modules = new Dictionary<string, IModule>();
        }

        private static RunLocation? _RunLocation;
        public static RunLocation? RunLocation
        {
            get
            {
                if (_RunLocation == null)
                {
                    _RunLocation = WooCoo.RunLocation.Server;
                }
                return _RunLocation;
            }
            set
            {
                _RunLocation = value;
            }
        }

        /// <summary>
        /// 系统默认的数据库上下文类型，该类型将用于DbContextManager类中
        /// </summary>
        public static Type DbContextType { get; set; }

        private static Type _DefaultEntityRepositoryType;
        /// <summary>
        /// 默认的实体数据处理类
        /// </summary>
        public static Type DefaultEntityRepositoryType
        {
            get { return _DefaultEntityRepositoryType; }
            set
            {
                _DefaultEntityRepositoryType = value;
                RepositoryFactoryHost.DefaultEntityRepositoryType = _DefaultEntityRepositoryType;
            }
        }
        public static Dictionary<string, IModule> Modules { get; set; }
    }

    public enum RunLocation
    {
        Web,
        WPF,
        SilverLight,
        Server
    }
}
